package apidemo.util;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class DateTimeHelpers {
	private final static int fONE_DAY = 1;
	private final static int fCLOSE_HOUR = 4;
	private final static int fCLOSE_MINUTE = 45;
	
	public static Date getToDayUserEnter(String theTime) {
		int hourPart = Integer.parseInt(theTime.substring(0, theTime.indexOf(":")));
		int minutePart = Integer.parseInt(theTime.substring(theTime.indexOf(":")+1, theTime.length()));
		
		Calendar today = new GregorianCalendar();
		Calendar result = new GregorianCalendar(today.get(Calendar.YEAR),
				today.get(Calendar.MONTH), today.get(Calendar.DATE), hourPart,
				minutePart);
		System.out.println("The job will be called at " + result.getTime());
		return result.getTime();
	}
	
	public static Date getToDay9PM() {
		Calendar today = new GregorianCalendar();
		Calendar result = new GregorianCalendar(today.get(Calendar.YEAR),
				today.get(Calendar.MONTH), today.get(Calendar.DATE), 22,
				35);
		System.out.println("The job will be called at " + result.getTime());
		return result.getTime();
	}
	
	public static Date getTomorrowMorning4am() {
		Calendar tomorrow = new GregorianCalendar();
		tomorrow.add(Calendar.DATE, fONE_DAY);
		Calendar result = new GregorianCalendar(tomorrow.get(Calendar.YEAR),
				tomorrow.get(Calendar.MONTH), tomorrow.get(Calendar.DATE),
				fCLOSE_HOUR, fCLOSE_MINUTE);
		System.out.println("The job will be called at " + result.getTime());
		return result.getTime();
	}

}
